package com.yuexun.dhdoctor.module.Government.adapter;

import android.view.View;
import android.widget.AbsListView;
import android.widget.TextView;

import com.yuexun.dhdoctor.R;
import com.yuexun.dhdoctor.module.main.bean.MenuItemBean;

import org.kymjs.kjframe.widget.AdapterHolder;
import org.kymjs.kjframe.widget.KJAdapter;

import java.util.Collection;

/**
 * Created by chenss on 2018/3/14 0014.
 */

public class MenuAdapter extends KJAdapter<MenuItemBean> {

    public MenuAdapter(AbsListView view, Collection<MenuItemBean> mDatas, int itemLayoutId) {
        super(view, mDatas, itemLayoutId);
    }

    @Override
    public void convert(AdapterHolder adapterHolder, MenuItemBean item, boolean isScrolling) {
        adapterHolder.setImageResource(R.id.iv_menu_icon,item.getMenuIconRes());
        adapterHolder.setText(R.id.tv_menu_text, item.getMenuText());
        TextView messageCount = adapterHolder.getView(R.id.ic_message_count);
        if(item.getCount() > 0){
            messageCount.setVisibility(View.VISIBLE);
            messageCount.setText(item.getCount()+ "");
        }else{
            messageCount.setVisibility(View.GONE);
        }
    }
}
